var tableData = {
	url : ctp + "/groupController/groupSearch.shtml",
	propertys : [ "NAME", "MONITOR", "TEL" ,"WORKERNUM","PROJECTNUM"],
	hrefs : [ [ "function=groupUpdate", "recId=REC_ID", "编辑", null ],[ "function=groupDelete", "recId=REC_ID", "删除", null ] ],
	//css:[null,null,null,null,"[STATE_CHAR][1=color:blue;,2=color:red;]"],//不同值的样式
	//maxLength:["TASKNAME=15"],
	checkBox:["REC_ID",true],
	startLoad : function() {
		getListData(this);
	}
};


function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	tableData.startLoad();
}
$(document).ready(function() {
	//页面中下拉框的渲染
	$('select').SumoSelect({
	placeholder: '请选择',
    csvDispCount: 4,
    captionFormat: '{0} Selected',
    forceCustomRendering: false,
    outputAsCSV : false,
    okCancelInMulti: false, 
    triggerChangeCombined : true
	});
	//页面加载时，加载列表
	searchData();

});


function groupDel() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要删除的记录！");
		return false;
	}
	jconfirm("del('" + recIds + "')", "是否要删除所选记录？");
}

function groupDelete(recIds) {
	jconfirm("del('" + recIds + "')", "是否要删除所选记录？");
}
function del(recIds) {
	$.ajax({
		url : ctp + "/groupController/groupDelete.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("删除成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
			} else {
				jalert(result);
			}
		}
	});
}

// 修改
function groupUpdate(recId) {
	location.href=ctp + "/groupController/groupUpdate.shtml?recId="+ recId;
}

//详情
function groupDetail(recId) {
	location.href=ctp + "/groupController/groupDetail.shtml?recId="+ recId;
}

// 新增
function groupAdd() {
	/*layui.layer.open({
        type: 2,
        area: ['1100px', '510px'],
        title: "班组新增",
        fixed: false,
        maxmin: false,
        content: ctp + "/groupController/groupAdd.shtml"
    });*/
	location.href=ctp + "/groupController/groupAdd.shtml";
}


// 重置密码
function resetPwd() {
	var recIds = getCheckIds(null, "groupid");
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("doReset('" + recIds + "')", "确定要重置所选用户的密码吗？");
}

function doReset(recIds) {
	$.ajax({
		url : ctp + "/groupController/resetPwd.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			jalert9(result);
			setTimeout(function() {
				searchData();
			}, 1000);
		}
	});
}


function groupDisable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要停用的用户！");
		return false;
	}
	jconfirm("Disable('" + recIds + "')", "是否要停用所选的用户？");
}
function Disable(recIds) {
	$.ajax({
		url : ctp + "/groupController/groupDisable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("停用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("停用用户失败！");
			}
		}
	});
}

function groupEnable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要启用的用户！");
		return false;
	}
	jconfirm("Enable('" + recIds + "')", "是否要启用所选的用户？");
}
function Enable(recIds) {
	$.ajax({
		url : ctp + "/groupController/groupEnable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("启用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("启用用户失败！");
			}
		}
	});
}


//导出系统用户
function workerExp(){
	jconfirm("exportWorker()","确认要导出工人数据吗？");	
}
function exportWorker(){
	var groupIds=getCheckIds();
	location.href=ctp+"/workerController/exportWorker.shtml?groupIds="+groupIds;
}


//用户信息导入界面跳转
function sysgroupImportpage(){
	dialogWin(550,450,ctp+"/groupController/sysgroupImportpage.shtml","用户信息导入");
}

function testFunction(){
	//layOpenWindow('新窗口1', '5','5','500','500','http://www.baidu.com');
	//layOpenWindow('新窗口2', '10','10','200','200','http://www.baidu.com');
	//layer.load(10); //风格1的加载
	//layConfirm('nihao',hello(1));
	dialogWin(550, 450, ctp + "/groupController/group.shtml", "");
}






















